package com.briup.day20;

public class Test_State {
    public static void main(String[] args) throws InterruptedException {
        Thread th1=new Thread("th1线程"){
            @Override
            public void run(){
                for(int i=0;i<6;i++){
                    if(i%3==0){
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    System.out.println("i: "+i);
                }
            }
        };
        //未启动start之前获取线程的状态
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println("-------------------------------------------------------");
        th1.start();
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        System.out.println(th1.getState());

        Thread.sleep(300);
        System.out.println(th1.getState());
        System.out.println(th1.getState());
        Thread.sleep(500);
        System.out.println(th1.getState());
        System.out.println(th1.getState());
    }
}
